package org.scs.carleton.ca.pgdt.core.internal.parser;

import java.util.List;

import org.scs.carleton.ca.pgdt.core.parser.nodes.IASTClause;
import org.scs.carleton.ca.pgdt.core.parser.nodes.IASTFunctor;
import org.scs.carleton.ca.pgdt.core.parser.nodes.IASTNode;
import org.scs.carleton.ca.pgdt.core.visitor.PrologVisitor;

public class ASTFunctorClause extends ASTClause implements IASTClause {
	protected IASTFunctor functor;
	
	public ASTFunctorClause(ASTTranslationUnit translationUnit, int type, IASTFunctor functor, List<IASTNode> body) {
		super(translationUnit, type, body);
		this.functor = functor;
	}

	@Override
	public IASTNode getHead() {
		return functor;
	}

	@Override
	public boolean accept(PrologVisitor visitor) {
		boolean visitChildren = visitor.visit(this);
		
		if (visitChildren) {
			//If the visitor wants to visit this node...
			functor.accept(visitor);
			for (IASTNode innerStructure : body) {
				innerStructure.accept(visitor);
			}
		}
		
		return visitChildren;
	}

}
